package com.t17;

import java.util.LinkedHashMap;

import static net.mindview.util.Print.print;
import static net.mindview.util.Print.printnb;

/**
 * Created by xuyiwei on 2018/8/15.
 */
public class LinkedHashMapDemo {
    public static void main(String[] args) {
        LinkedHashMap<Integer,String> linkedHashMap = new LinkedHashMap<>(new CountingMapData(9));
        print(linkedHashMap);
        //这个方法是用来设定LinkedHashMap,使之采用基于访问的最小使用LRU算法，于是没有被访问过的元素就会出现在队列的前面
        linkedHashMap.putAll(new CountingMapData(9));
        print(linkedHashMap);
        for(int i=0;i<6;i++){
            linkedHashMap.get(i);
        }
        print(linkedHashMap);
        linkedHashMap.get(0);
        print(linkedHashMap);
        /**
         *{0=A0, 1=B0, 2=C0, 3=D0, 4=E0, 5=F0, 6=G0, 7=H0, 8=I0}
         {0=A0, 1=B0, 2=C0, 3=D0, 4=E0, 5=F0, 6=G0, 7=H0, 8=I0}
         {6=G0, 7=H0, 8=I0, 0=A0, 1=B0, 2=C0, 3=D0, 4=E0, 5=F0}
         {6=G0, 7=H0, 8=I0, 1=B0, 2=C0, 3=D0, 4=E0, 5=F0, 0=A0}
         */
    }
}
